package yxy.game.pm2.module.tower;

import java.util.ArrayList;
import java.util.Collection;

import yxy.game.pm2.bean.Currency;
import yxy.game.pm2.bean.mq.CCReason;
import yxy.game.pm2.module.CurrencyHandle;
import yxy.game.pm2.module.battle.ISettlement;

/** 爬塔的战斗结算 */
public class SettlementTower implements ISettlement {
	// bean===========================================================================

	private String playerCode;
	private ArrayList<Currency> rewards = new ArrayList<>();
	private int floor;

	public String getPlayerCode() {
		return playerCode;
	}

	public void setPlayerCode(String playerCode) {
		this.playerCode = playerCode;
	}

	public ArrayList<Currency> getRewards() {
		return rewards;
	}

	public void setRewards(ArrayList<Currency> rewards) {
		this.rewards = rewards;
	}

	public int getFloor() {
		return floor;
	}

	public void setFloor(int floor) {
		this.floor = floor;
	}
	// func===========================================================================

	@Override
	public void settle() {
		new CurrencyHandle().addCurrency(playerCode, CCReason.修炼塔, getRewards());
		new TowerHandle().nextFloor(getPlayerCode(), getFloor());
	}

	@Override
	public Collection<Currency> reward() {
		return getRewards();
	}

	static public SettlementTower create(String playerCode, int floor, boolean first) {
		SettlementTower settlement = new SettlementTower();
		try {
			settlement.setPlayerCode(playerCode);
			settlement.setFloor(floor);
			settlement.setRewards(new ArrayList<>(TowerHandle.floorRewards(floor,first)));

			return settlement;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

}
